Warning in instance$preRenderHook(instance): It seems your data is too big
for client-side DataTables. You may consider server-side processing: https://
rstudio.github.io/DT/server.html
Summarizing and Visualizing:
3.1 (Also “spicing” up this one)
statesnames_a |>pivot_wider(names_from = Sex, values_from = Count) |>filter(Name =='Allison') |>mutate(across(c('F', 'M'), ~replace_na(.x, 0))) |>group_by(State) |>summarize(across(F:M, sum)) |>rename("Number of Male-assigned Babies"="M","Number of Female-assigned Babies"="F") |>datatable(head(statesnames_a),caption = htmltools::tags$caption(style ='caption-side: bottom; text-align: center;','Table 1: ', htmltools::em('The Number of babies are mostly Female-assigned ') )) |>formatStyle('State', color ='blue', backgroundColor ='green', fontWeight ='bold')
statesnames_a |>filter(Name =='Allan'| Name =='Alan'| Name =='Allen', State =='PA'| State =='CA', Year ==2000) |>group_by(Name, State) |>summarize(sum(Count)) |>rename("Count"=`sum(Count)`) |>pivot_wider(names_from = Name, values_from = Count) |>rename("# of Alan"="Alan","# of Allan"="Allan","# of Allen"="Allen") |>kable()
`summarise()` has grouped output by 'Name'. You can override using the
`.groups` argument.
State
# of Alan
# of Allan
# of Allen
CA
584
131
176
PA
51
12
56
Percents Challenge:
statesnames_a |>filter(Name =='Allan'| Name =='Alan'| Name =='Allen', State =='PA'| State =='CA', Year ==2000) |>group_by(Name, State) |>summarize(sum(Count)) |>rename("Count"=`sum(Count)`) |>pivot_wider(names_from = Name, values_from = Count) |>mutate(Total = Alan + Allan + Allen,Alan = Alan / Total,Allan = Allan / Total,Allen = Allen / Total) |>rename("# of Alan"="Alan","# of Allan"="Allan","# of Allen"="Allen") |>select(-Total) |>kable()
`summarise()` has grouped output by 'Name'. You can override using the
`.groups` argument.